package cn.allen.controller;

import javax.annotation.Resource;


import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.pagehelper.PageSerializable;
import com.power.common.model.CommonResult;
import cn.allen.model.TUser;
import cn.allen.service.TUserService;

/**
 * TUser Information Operation Interface
 * @author user on 2019/02/07.
 */
@RestController
@RequestMapping("tUser")
public class TUserController {
    /**
     * log
     */
    private static Logger logger = LoggerFactory.getLogger(TUserController.class);

	@Resource
	private TUserService tUserService;

    /**
	 * Add tUser info
	 * @param entity tUser info
	 * @return
	 */
	@PostMapping(value = "/add")
	public CommonResult save(TUser entity) {
		return tUserService.save(entity);
	}

    /**
	 * Update tUser info
	 * @param entity tUser info
	 * @return
	 */
	@PostMapping(value = "/update")
	public CommonResult update(TUser entity) {
		return tUserService.update(entity);
	}

    /**
	 * Delete tUser by id
	 * @param id tUser id
	 * @return
	 */
	@GetMapping(value = "/delete/{id}")
	public CommonResult delete(@PathVariable Long id) {
		return tUserService.delete(id);
	}

    /**
	 * Query tUser by id
	 * @param id tUser id
	 * @return
	 */
	@GetMapping(value = "/query/{id}")
	public CommonResult<TUser> queryById(@PathVariable Long id) {
		return tUserService.queryById(id);
	}

    /**
	 * Pagination query tUser information
	 * @param offset page offset
	 * @param limit page limit
	 * @return
	 */
    @GetMapping(value = "/page/{offset}/{limit}")
    public PageSerializable<TUser> queryPage(@PathVariable int offset,@PathVariable int limit) {
        return tUserService.queryPage(offset,limit);
    }
}